package com.cms.admin.service.common.impl;

import com.cms.admin.mapper.EntityListMapper;
import com.cms.admin.model.EntityList;
import com.cms.admin.model.EntityListExt;
import com.cms.admin.model.PageBean;
import com.cms.admin.service.common.EntityService;

import java.util.List;

/**
 * Created by YYY-Work on 2017/4/28.
 */
public class EntityServiceImpl implements EntityService{

    private EntityListMapper entityListMapper;

    @Override
    public List<EntityList> queryAllEntityList() {
        return entityListMapper.selectAll();
    }

    @Override
    public List<EntityList> queryEntityList(PageBean page, EntityListExt example){

        int count=getRowCount(example);
        page.setAllRow(count);

        example.setOffset(page.getOffset());
        example.setPageSize(page.getPageSize());

        return entityListMapper.selectByConditionWithLimit(example);
    }

    @Override
    public List<EntityList> getEntityListByName(EntityListExt example) {
        return entityListMapper.selectByName(example);
    }

    @Override
    public List<EntityList> getEntityListByEntityID(EntityListExt example) {
        return entityListMapper.selectByEntityID(example);
    }

    @Override
    public int addEntityList(EntityListExt record) {
        return entityListMapper.insertSelective(record);
    }

    @Override
    public int getRowCount(EntityListExt example) {
        return entityListMapper.countByCondition(example);
    }

    @Override
    public int updateEntityByEntityID(EntityListExt example) {
        return entityListMapper.updateByEntityID(example);
    }

    public EntityListMapper getEntityListMapper() {
        return entityListMapper;
    }

    public void setEntityListMapper(EntityListMapper entityListMapper) {
        this.entityListMapper = entityListMapper;
    }
}
